/*******************************************************************************
 Configuration Information:
 Repository: Integrity Source
 Name      : $RCSfile: AR_CD_RackPosnCtrlErrPrelookup_tl_lut.c $
 Version   : $Revision: 1.3 $
 Author    : $Author: Jack Jin (JinC5) $
 Date      : $Date: 2018/09/14 18:33:13IST $
 Location  : $ProjectName: /Steering/Projects/Geely/CMA_DP/PR48756_LVS_ENG_APP_Geely_CMA_EPS_DP_SYS_HRoom_AP/30_Software/3040_Design/S2-Application/01-Development/V00-Mainline/04-Components/ActiveReturn_Ear/Source/project.pj $
********************************************************************************

   ZF Friedrichshafen AG owns the copyright in this document and associated
   documents and all rights are reserved.  These documents must
   not be used for any purpose other than that for which they
   are supplied and must not be copied in whole or in part or
   disclosed to others without prior written consent of ZF Friedrichshafen AG.
   Any copy of this drawing or document made by any method
   must also include a copy of this legend.

   (C) ZF Friedrichshafen AG 2018

*******************************************************************************/
/**************************************************************************************************\
 *** 
 *** Simulink model       : AR_CD_RackPosnCtrlErrPrelookup_tl
 *** TargetLink subsystem : AR_CD_RackPosnCtrlErrPrelookup_tl
 *** Codefile             : AR_CD_RackPosnCtrlErrPrelookup_tl_lut.c
 ***
 *** Generated by TargetLink, the dSPACE production quality code generator
 *** Model version: 1.106
 *** Generation date: 2018-09-14 10:59:38
 ***
 *** CODE GENERATOR OPTIONS:
 *** Code generation mode                     : AUTOSAR
 *** AUTOSAR version                          : 4.2.2
 *** Compiler                                 : <unknown>
 *** Target                                   : Generic
 *** ANSI-C compatible code                   : yes
 *** Code Optimization                        : enabled
 *** Constant style                           : decimal
 *** Clean code option                        : enabled
 *** Logging mode                             : Do not log anything
 *** Code Coverage                            : disabled
 *** Generate empty conditional branches      : disabled
 *** Loop unroll threshold                    : 5
 *** Shift mode                               : automatic
 *** Handle unscaled SF expr. with TL type    : enabled
 *** Assignment of conditions                 : AllBooleanOutputs 
 *** Scope reduction only to function level   : disabled
 *** Exploit ranges if not erasable           : disabled
 *** Exploit Compute Through Overflow         : never
 *** Linker sections                          : enabled
 *** Enable Assembler                         : disabled
 *** Variable name length                     : unlimited
 *** Use global bitfields                     : disabled
 *** Stateflow: use of bitfields              : enabled
 *** State activity encoding limit            : 8
 *** Omit zero inits in restart function      : disabled
 *** Share functions between TL subsystems    : disabled
 *** Generate 64bit functions                 : disabled
 *** Inlining Threshold                       : 6
 *** Line break limit                         : 100
 *** Target optimized boolean data type       : enabled
 *** Keep saturation elements                 : disabled
 *** Extended variable sharing                : disabled
 *** Extended lifetime optimization           : enabled
 *** Style definition file                    : C:\Program Files\dSPACE TargetLink 4.2\Matlab\Tl\Con
 ***                                            fig\codegen\cconfig.xml
 *** Root style sheet                         : C:\Program Files\dSPACE TargetLink 4.2\Matlab\Tl\XML
 ***                                            \CodeGen\Stylesheets\TL_CSourceCodeSS.xsl
 ***
 *** SUBSYS                   CORRESPONDING SIMULINK SUBSYSTEM
 *** SAR_CD_061               AR_CD_RackPosnCtrlErrPrelookup_tl
 *** SAR_CD_062               AR_CD_RackPosnCtrlErrPrelookup_tl/AR_CD_RackPosnCtrlErrPrelookup
 *** SAR_CD_063               AR_CD_RackPosnCtrlErrPrelookup_tl/DocFunction
 *** SAR_CD_064               AR_CD_RackPosnCtrlErrPrelookup_tl/IncludeAppHeader
 *** SAR_CD_065               AR_CD_RackPosnCtrlErrPrelookup_tl/AR_CD_RackPosnCtrlErrPrelookup/ZFDiv
 ***                          A_fabs
 *** SAR_CD_066               AR_CD_RackPosnCtrlErrPrelookup_tl/DocFunction/EmptySubsystem
 *** 
 *** SUBSYS                   CORRESPONDING MODEL BLOCK (REFERENCED MODEL)
 *** 
 *** SF-NODE   CORRESPONDING STATEFLOW NODE                           DESCRIPTION
 *** 
 *** TargetLink version      : 4.2p2 from 27-Nov-2017
 *** Code generator version  : Build Id 4.2.0.33 from 2017-11-28 14:39:24

\**************************************************************************************************/

#ifndef AR_CD_RACKPOSNCTRLERRPRELOOKUP_TL_LUT_C
#define AR_CD_RACKPOSNCTRLERRPRELOOKUP_TL_LUT_C

/*----------------------------------------------------------------------------*\
  DEFINES (OPT)
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  INCLUDES
\*----------------------------------------------------------------------------*/

#include "AR_CD_RackPosnCtrlErrPrelookup_tl_lut.h"

/*----------------------------------------------------------------------------*\
  ENUMS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  DEFINES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  TYPEDEFS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  VARIABLES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  PARAMETERIZED MACROS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION PROTOTYPES
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  INLINE FUNCTIONS
\*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*\
  FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/

/**************************************************************************************************\
 ***  FUNCTION:
 ***      TabIdxS48T3078_AR_CD_06
 *** 
 ***  DESCRIPTION:
 ***      Automatic generated function for PreLook-Up Index Search blocks.
 *** 
 ***  PARAMETERS:
 ***      Type               Name                Description
 ***      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ***      const float32 *    x_table             pointer to x-axis vector
 ***      uint8              N                   number of values in x-axis vector
 ***      float32            x                   table input
 ***      uint8 *            irx                 table output
 ***      float32 *          fraction            table output
 ***
 ***  RETURNS:
 ***      void
 ***
 ***  SETTINGS:
 ***      Search algorithm...................: ascending linear search.
 ***      Output configuration...............: output index and fraction, two variables
 ***
\**************************************************************************************************/
void TabIdxS48T3078_AR_CD_06(const float32 * x_table, uint8 N, float32 x, uint8 * irx, float32 *
  fraction)
{
   /* SLLocal: Default storage class for local variables | Width: 8 */
   uint8 Aux_U8;

   /* Saturation. */
   if (x <= *x_table) {
      *irx = 0;
      *fraction = 0.F;
   }
   else {
      if (x >= x_table[N - 1]) {
         *irx = N - 1;
         *fraction = 0.F;
      }
      else {
         Aux_U8 = 0;

         /* Linear search, start low. */
         x_table++;
         while (x >= *(x_table++)) {
            Aux_U8++;
         }
         x_table -= 2;
         *irx = Aux_U8;
         *fraction = (x - x_table[0]) / (x_table[1] - x_table[0]);
      }
   }
}

/*----------------------------------------------------------------------------*\
  MODULE LOCAL FUNCTION DEFINITIONS
\*----------------------------------------------------------------------------*/
#endif /* AR_CD_RACKPOSNCTRLERRPRELOOKUP_TL_LUT_C */
/*----------------------------------------------------------------------------*\
  END OF FILE
\*----------------------------------------------------------------------------*/
